package extend.animal;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Pet pet = null;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输如宠物名称：");
        String name = scanner.next();
        System.out.println("请输入宠物类型：1.猫 2.狗");
        int type = scanner.nextInt();
        switch (type) {
            case 1:
                pet = new Cat();
                System.out.println("请输入颜色：");
                ((Cat) pet).color = scanner.next();
                break;
            case 2:
                pet = new Dog();
                System.out.println("请输入品种：");
                ((Dog) pet).type = scanner.next();
                break;
            default:
                System.out.println("输入错误");
        }

        pet.name = name;
        pet.print();
        pet.name = name;
    }
}


